package com.baizhi.service.impl;

import com.baizhi.dao.UserDAO;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import com.baizhi.utli.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImpl implements UserService {
    @Override
    public User selectUserByName(String userName) {
        SqlSession sqlSession = MyBatisUtils.openSession();
        User user = null;
        try {
            UserDAO dao = sqlSession.getMapper(UserDAO.class);
            user = dao.selectUserByName(userName);
            sqlSession.commit();
        } catch (Exception e) {
            sqlSession.rollback();
            e.printStackTrace();
        } finally {
            MyBatisUtils.close(sqlSession);
        }
        return user;
    }
}
